<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/accountData.js"></script>
    <script src="./js/jquery.min.js"></script>
    <script src="./js/public.js"></script>
    <link rel="icon" href="./img/icon_game.png" type="image/x-icon">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        #gameIframe {
            width: 100%;
            height: 90vh;
        }

        .ad {
            text-align: center;
            margin: 0 auto;
        }

        .back {
            width: 50px;
            position: fixed;
            top: 40px;
            left: 0px;
            opacity: 0.7;
        }

        .mask {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background-color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            font-weight: bold;
            z-index: 999999;
        }

        .mask .countdown {
            position: absolute;
            right: 10px;
            bottom: 10px;
        }

        .game-list {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
        }

        .game-list a {
            width: 18%;
        }

        .game-list a img {
            width: 100%;
            height: 100%;
        }

    </style>
</head>

<body>
    <div class="mask">
        <img src="./img/loading.gif" height="200">
        LOADING...
        <span class="countdown"></span>
    </div>
    <iframe id="gameIframe" src="./utils/index.html" webkitallowfullscreen='true' mozallowfullscreen='true'
        allowfullscreen='true' webkit-playsinline='true' scrolling='no' seamless frameborder='0'
        style='display:block;overflow:hidden;'></iframe>
    <img src="./img/Home Loan.png" class="back">
    <div class="game-list" style="margin-top: 5px">
        
    </div>
    <!-- <div class="ad" id="bottomAd">
    </div> -->
    <script>
        var gameChannelId = getQueryVariable('gameChannelId') ? this.getQueryVariable('gameChannelId') : 5870
        var accountInfo = googleAccount.hasOwnProperty(gameChannelId) ? googleAccount[gameChannelId] : googleAccount[5870]
        loadGAScript(accountInfo.ga, accountInfo)
        getAdData(accountInfo.adChannel)
        $('#bottomAd').append(`<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7477868724797302"
            data-ad-slot="${accountInfo.pc.detail.bottom}" data-ad-format="auto" data-full-width-responsive="true"></ins>
        <script>(adsbygoogle = window.adsbygoogle || []).push({});<\/script>`)
    </script>
    <script>
        const games = [{
            gameId: "2387",
            gameLogo: "./webp/c69f8321010441d3ba76b61332af9574.webp",
        }, {
            gameId: "1473",
            gameLogo: "./webp/4a5a1b05131747cba6679b86106e950e.webp",
        }, {
            gameId: "1112",
            gameLogo: "./webp/324d20f6b33a4ffb807bdca66b165516.Webp",
        }, {
            gameId: "2054",
            gameLogo: "./webp/e756f1b6adbf4ac4bc0bcf34fa96bf05.webp",
        }, {
            gameId: "1098",
            gameLogo: "./webp/23c61ce9aaf84fd5bad4a0854d46cf0c.webp",
        }]

        function renderGames() {
            let str = ''
            for (const item of games) {
                str += `<a href="detail.html?gameChannelId=${gameChannelId}&gameId=${item.gameId}">
                            <img style="border-radius: 3px;" src="${item.gameLogo}" alt="${item.gameName}">
                        </a>`
            }
            $('.game-list').append(str)
        }

        renderGames()
    </script>
    <script>
        adPrepare()
        // preAd()
        var gameChannelId = getQueryVariable('gameChannelId') ? this.getQueryVariable('gameChannelId') : 5870
        var gameFileName = getQueryVariable('gameFileName')
        localStorage.setItem('gameName', gameFileName || 'ShoesDiy')
        // $('#gameIframe').attr('src', `./utils/index.html`)
        $('.back').click(() => {
            location.href = `index.html?gameChannelId=${gameChannelId}`
        })
    </script>
    <script>
        function countdown(i = 5) {
            var timer = 0
            if (i < 0) {
                clearTimeout(timer)
                $('.mask').hide()
                return
            }
            timer = setTimeout(() => {
                $('.countdown').html(`Enter the game in ${i} seconds`)
                countdown(i - 1)
            }, 1000)
        }

        countdown()
    </script>
    <script>
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments); }
        gtag('js', new Date());

        gtag('config', accountInfo.ga);
    </script>
    <script>
        if (gameChannelId == 4163) {
            (function (h, o, t, j, a, r) {
                h.hj = h.hj || function () { (h.hj.q = h.hj.q || []).push(arguments) };
                h._hjSettings = { hjid: 3378431, hjsv: 6 };
                a = o.getElementsByTagName('head')[0];
                r = o.createElement('script'); r.async = 1;
                r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
                a.appendChild(r);
            })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
        }
    </script>
</body>
<script>
    var pattern = /^aswif/;
      window.addEventListener('blur', function() {
          if (pattern.test(document.activeElement.id)) {
            gtag('event', 'clickAd')
          }
      })
  </script>
</html>